/*
PearReview - The peer review assistant.
Copyright (C) 2009  Dimitrij Pankratz, Anton Musichin
http://www.pearreview.com, info@pearreview.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

package com.pearreview.ui.slidebox;

import java.text.DateFormat;

import javax.swing.Action;
import javax.swing.GroupLayout;
import javax.swing.JPanel;
import javax.swing.LayoutStyle;

import com.pearreview.ui.FormLabel;
import com.pearreview.application.Messages;
import com.pearreview.util.review.Meeting;

public class MeetingSlideBox extends SlideBox<Meeting> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5068829765784764189L;

	public MeetingSlideBox(Meeting meeting, Action delete, Action edit) {
		super(meeting, delete, edit);
		slidedHeight = 150;
	}
	
	@Override
	protected String getCaption() {
    	return Messages.getString("PearReview.Moderator.meetings.date") + 
    			": " + DateFormat.getDateInstance().format(
    			element.getPlannedDate().getTime());
    }
    
	@Override
    protected void initContent(JPanel containerBottom) {

		FormLabel meetingDateLabel = new FormLabel(
				Messages.getString("PearReview.Moderator.meetings.date"));
		FormLabel meetingDate = new FormLabel(
				DateFormat.getDateInstance().format(
						element.getPlannedDate().getTime()));
		FormLabel meetingStartTimeLabel = new FormLabel(
				Messages.getString("PearReview.Moderator.meetings.start"));
		FormLabel meetingStartTime = new FormLabel(
				DateFormat.getTimeInstance(DateFormat.SHORT).format(
						element.getPlannedStart().getTime()));
		FormLabel meetingEndTimeLabel = new FormLabel(
				Messages.getString("PearReview.Moderator.meetings.end"));
		FormLabel meetingEndTime = new FormLabel(
				DateFormat.getTimeInstance(DateFormat.SHORT).format(
						element.getPlannedEnd().getTime()));
		FormLabel meetingLocationLabel = new FormLabel(
				Messages.getString("PearReview.Moderator.meetings.place"));
		FormLabel meetingLocation = new FormLabel(
				element.getPlannedLocation());
		FormLabel meetingCommentsLabel = new FormLabel(
				Messages.getString("PearReview.Moderator.meetings.comments"));
		FormLabel meetingComments = new FormLabel(element.getComments());
  
		
		//containerBottom.setLayout(new BorderLayout());

		GroupLayout layout = new GroupLayout(containerBottom);
		
		containerBottom.setLayout(layout);
		layout.setHorizontalGroup(
			layout.createParallelGroup()
				.addGroup(layout.createSequentialGroup()
					.addContainerGap()
					.addGroup(layout.createParallelGroup()
						.addGroup(layout.createSequentialGroup()
							.addGroup(layout.createParallelGroup()
								.addGroup(GroupLayout.Alignment.TRAILING, 
										layout.createSequentialGroup()
									.addGroup(layout.createParallelGroup()
										.addComponent(meetingDateLabel, 
												GroupLayout.Alignment.LEADING, 
												GroupLayout.DEFAULT_SIZE, 
												50, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(meetingStartTimeLabel,
												GroupLayout.Alignment.LEADING, 
												GroupLayout.DEFAULT_SIZE, 
												50, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(meetingEndTimeLabel,
												GroupLayout.Alignment.LEADING, 
												GroupLayout.DEFAULT_SIZE, 
												50, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(meetingLocationLabel,
												GroupLayout.Alignment.LEADING, 
												GroupLayout.DEFAULT_SIZE, 
												50,
												GroupLayout.PREFERRED_SIZE)
										.addComponent(meetingCommentsLabel,
												GroupLayout.Alignment.LEADING, 
												GroupLayout.DEFAULT_SIZE, 
												50, 
												GroupLayout.PREFERRED_SIZE))
									.addGap(57, 57, 57)
									.addGroup(layout.createParallelGroup(
											GroupLayout.Alignment.TRAILING)
										.addComponent(meetingComments, 
												GroupLayout.Alignment.LEADING, 
												10, 
												GroupLayout.PREFERRED_SIZE, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(meetingLocation, 
												GroupLayout.Alignment.LEADING, 
												10, 
												GroupLayout.PREFERRED_SIZE, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(meetingEndTime, 
												GroupLayout.Alignment.LEADING, 
												10, 
												GroupLayout.PREFERRED_SIZE, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(meetingStartTime, 
												GroupLayout.Alignment.LEADING, 
												10, 
												GroupLayout.PREFERRED_SIZE, 
												GroupLayout.PREFERRED_SIZE)
										.addComponent(meetingDate, 
												GroupLayout.Alignment.LEADING, 
												10, 
												GroupLayout.PREFERRED_SIZE, 
												GroupLayout.PREFERRED_SIZE))
									.addGap(10, 10, 10))))))
								
		);
		layout.setVerticalGroup(
			layout.createParallelGroup()
				.addGroup(layout.createSequentialGroup()
					.addContainerGap()
					.addGroup(layout.createParallelGroup(
							GroupLayout.Alignment.BASELINE)
						.addComponent(meetingDateLabel)
						.addComponent(meetingDate, 
								GroupLayout.PREFERRED_SIZE, 
								GroupLayout.DEFAULT_SIZE, 
								GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(layout.createParallelGroup()
						.addComponent(meetingStartTimeLabel)
						.addComponent(meetingStartTime, 
								GroupLayout.PREFERRED_SIZE, 
								GroupLayout.DEFAULT_SIZE, 
								GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(layout.createParallelGroup()
						.addComponent(meetingEndTimeLabel)
						.addComponent(meetingEndTime, 
								GroupLayout.PREFERRED_SIZE, 
								GroupLayout.DEFAULT_SIZE, 
								GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(layout.createParallelGroup()
							.addComponent(meetingLocationLabel)
							.addComponent(meetingLocation, 
									GroupLayout.PREFERRED_SIZE, 
									GroupLayout.DEFAULT_SIZE, 
									GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(
								LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(layout.createParallelGroup()
							.addComponent(meetingCommentsLabel)
							.addComponent(meetingComments, 
									GroupLayout.PREFERRED_SIZE, 
									GroupLayout.DEFAULT_SIZE, 
									GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED))
		);
    }
}